use std::{io, process};
use crate::tools::config::{Config};

pub fn read_csv(file: String, t: (String, String)) -> String {
    let config = Config::new(
        t.clone().0,
        t.clone().1,
        file.clone()).unwrap_or_else(|err| {
        println!("错误信息：{}", err);
        process::exit(1);
    });

    eprintln!("在文件：{}", config.filename);

    match Config::run(config) {
        Ok(c) => {
            c
        }
        Err(err) => {
            println!("跑错：{}", err);
            "参数错误".to_string()
        }
    }
}

pub fn _text() -> (String, String) {
    println!("------------------------------------");
    println!("格式化!");
    let mut remove_start = String::new();
    let mut remove_end = String::new();
    println!("去头(默认0)");
    io::stdin()
        .read_line(&mut remove_start)
        .expect("Failed to read line");
    println!("去尾(默认0)");
    io::stdin()
        .read_line(&mut remove_end)

        .expect("Failed to read line");
    (remove_start, remove_end)
}